package com.sz.web.common.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

//@Component
public class HeartbeatLogTask {

    private static final Logger logger = LoggerFactory.getLogger(HeartbeatLogTask.class);

    @Scheduled(cron = "0/30 * * * * ?") // 每30秒执行一次
    public void hearbeatLog(){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
        String time = sdf.format(date);
        logger.info("[项目心跳] 项目运行中,当前时间为:"+time);
    }
}